package com.jsh.erp.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import javax.annotation.PostConstruct;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;

@Component
public class AppConfig {

    @Value("${admin.roleId}")
    private String roleId;

    private Set<Long> roleIdSet;


    @PostConstruct
    public void init() {
        if (StringUtils.isEmpty(roleId)) {
            return;
        }
        Set<Long> collect = Arrays.stream(roleId.split(","))
                .map(Long::parseLong)
                .collect(Collectors.toSet());
        roleIdSet = collect;
    }


    public Set<Long> getRoleIdSet() {
        return roleIdSet;
    }

    public void setRoleIdSet(Set<Long> roleIdSet) {
        this.roleIdSet = roleIdSet;
    }
}
